package cfdt.ldl.business.api.feign.fallback;

import cfdt.common.enums.CommonCodeEnum;
import cfdt.common.vo.ObjectBaseResponse;
import cfdt.common.vo.PageBaseResponse;
import cfdt.ldl.business.api.request.GetLawyerInfoListBusinessRequest;
import cfdt.ldl.business.api.response.GetLawyerInfoListBusinessResponse;
import cfdt.ldl.business.api.feign.BusinessFeign;
import cfdt.ldl.core.entity.LawyerInfo;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * 
 * <pre>
 * Modify Information:
 * Author       Date          Description
 * ============ ============= ============================
 * wangxiao      2021年8月16日上午9:51:24      创建 FallBack
 *
 * </pre>
 */
@Component
public class BusinessFallback implements FallbackFactory<BusinessFeign> {
    
    private final Logger logger = LoggerFactory.getLogger(getClass().getName());

    @Override
    public BusinessFeign create(Throwable cause) {
        logger.error("请求律所服务异常", cause);
        return new BusinessFeign() {
            @Override
            public PageBaseResponse<LawyerInfo> getLawyerInfoList(GetLawyerInfoListBusinessRequest request) {
                return PageBaseResponse.error(CommonCodeEnum.CODE_2003);
            }
        };
    }

}
